package com.example.yichuangyun.mvvm.ui.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.DataBindingHolder;
import com.example.yichuangyun.R;
import com.example.yichuangyun.databinding.ItemOrderDetailsBusinessBinding;
import com.example.yichuangyun.model.order.BusinessRecordModel;

public class OrderBusinessAdapter extends BaseQuickAdapter<BusinessRecordModel.OrderBusinessModel, DataBindingHolder<ItemOrderDetailsBusinessBinding>> {

    @Override
    protected void onBindViewHolder(@NonNull DataBindingHolder<ItemOrderDetailsBusinessBinding> itemOrderDetailsBusinessBindingDataBindingHolder, int i, @Nullable BusinessRecordModel.OrderBusinessModel businessModel) {
        ItemOrderDetailsBusinessBinding binding = itemOrderDetailsBusinessBindingDataBindingHolder.getBinding();
        binding.setBusinessModel(businessModel);
        binding.line.setVisibility(i == getItemCount() - 1 ? View.GONE : View.VISIBLE);
    }

    @NonNull
    @Override
    protected DataBindingHolder<ItemOrderDetailsBusinessBinding> onCreateViewHolder(@NonNull Context context, @NonNull ViewGroup viewGroup, int i) {
        return new DataBindingHolder<>(R.layout.item_order_details_business, viewGroup);
    }
}
